﻿<UserControl x:Class="Terry.PlayButton3D"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="30" Width="30"
    >
        <Viewport3D Name="_viewport" ClipToBounds="True" HorizontalAlignment="Stretch">

            <!-- Defines the camera used to view the 3D object. -->
            <Viewport3D.Camera>
                <PerspectiveCamera Position="0,0,3.5" LookDirection="0,0,-1" FieldOfView="60" />
            </Viewport3D.Camera>

            <!-- The ModelVisual3D children contain the 3D models -->
            <Viewport3D.Children>

                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <DirectionalLight Color="White" Direction="-0.612372,-0.5,-0.612372"/>
                    </ModelVisual3D.Content>
                </ModelVisual3D>

                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <AmbientLight Color="White"/>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <GeometryModel3D>
                            <GeometryModel3D.Geometry>
                                <MeshGeometry3D
                                     TriangleIndices="0,3,1 1,3,4 3,0,5 5,0,2 5,2,4 4,2,1 5,4,3 0,1,2"
                                     TextureCoordinates="1,0 1,0 1,0 0.9,0 0.9,0 1,0"
                                     Positions="-1,-1,-0.2 1,0,-0.2 -1,1,-0.2 -1,-1,0.2 1,0,0.2 -1,1,0.2" />
                            </GeometryModel3D.Geometry>
                            <GeometryModel3D.Material>
                                <MaterialGroup>
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5" Opacity="0.9">
                                                <LinearGradientBrush.GradientStops>
                                                    <GradientStop Color="LightGreen" Offset="0" />
                                                    <GradientStop Color="Green" Offset="1" />
                                                </LinearGradientBrush.GradientStops>
                                            </LinearGradientBrush>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                    <SpecularMaterial Brush="White" SpecularPower="2"/>
                                </MaterialGroup>
                            </GeometryModel3D.Material>
                            <GeometryModel3D.Transform>
                                <Transform3DGroup>
                                    <ScaleTransform3D/>
                                    <RotateTransform3D>
                                        <RotateTransform3D.Rotation>
                                            <QuaternionRotation3D x:Name="_modelRotation" Quaternion="Identity"/>
                                        </RotateTransform3D.Rotation>
                                    </RotateTransform3D>
                                </Transform3DGroup>
                            </GeometryModel3D.Transform>
                        </GeometryModel3D>
                    </ModelVisual3D.Content>
                </ModelVisual3D>

            </Viewport3D.Children>

            <Viewport3D.Triggers>
                <EventTrigger RoutedEvent="Viewport3D.Loaded">
                    <BeginStoryboard>
                        <Storyboard x:Name="_storyboard">
                            <QuaternionAnimation
                                Name="_quaternionAnimation"
                                IsAdditive="True" 
                                Duration="0:0:05" 
                                DecelerationRatio="1"
                                FillBehavior="HoldEnd"
                                Storyboard.TargetName="_modelRotation"
                                Storyboard.TargetProperty="Quaternion" 
                                                 />
                            <!--
                                IsCumulative="True"
                            -->
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Viewport3D.Triggers>

        </Viewport3D>
</UserControl>
